//
//  YuLeCollectionCell.swift
//  StudyDY
//
//  Created by yinchangming on 2018/7/10.
//  Copyright © 2018年 yinchangming. All rights reserved.
//

import UIKit
let kItemYuLeID="kItemYuLeID"
class YuLeCollectionCell: UICollectionViewCell {

    @IBOutlet weak var itemYuLeCollctionView: UICollectionView!
    var menus:[AnchorCatgary]?{
        didSet{
            itemYuLeCollctionView.reloadData()
        }
    }
    override func awakeFromNib() {
        super.awakeFromNib()
        itemYuLeCollctionView.register(UINib(nibName: "GameCollectionCell", bundle: nil), forCellWithReuseIdentifier: kItemYuLeID)
    
    }
    override func layoutSubviews() {
        super.layoutSubviews()
        let  layout = itemYuLeCollctionView.collectionViewLayout as! UICollectionViewFlowLayout
        layout.itemSize=CGSize(width: (kScreenW-30)/4, height:90)
        itemYuLeCollctionView.collectionViewLayout = layout
    }
}
extension YuLeCollectionCell : UICollectionViewDataSource{
    func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
        return  menus?.count ?? 0
    }
    
    func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
        let  cell = collectionView.dequeueReusableCell(withReuseIdentifier: kItemYuLeID, for: indexPath) as! GameCollectionCell
        cell.catgary=menus?[indexPath.item]
        cell.clipsToBounds=true
        return cell
    }
    
    
}
